package com.xps.purifierapp.serciver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.jude.utils.JUtils;
import com.xps.purifierapp.App;

import cn.jpush.android.api.JPushInterface;

public class PushReceiver extends BroadcastReceiver {
    public static final String TAG = "PushReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        Bundle bundle = intent.getExtras();
        Log.d(TAG, "onReceive - " + intent.getAction());
        if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
            //收到自定义消息
        } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {     //自定义消息可以发送json数据
            System.out.println("收到了自定义消息。消息内容是：" + bundle.getString(JPushInterface.EXTRA_MESSAGE));
        } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
            System.out.println("收到了通知");
            App.getInstance().JPuchNotice();
        } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
            System.out.println("用户点击打开了通知");
        } else if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
            JUtils.Log("Received RegId:", JPushInterface.getRegistrationID(context));
        } else {
            Log.d(TAG, "Unhandled intent - " + intent.getAction());
        }
    }
}
